const mongoose = require('mongoose')
const Schema = mongoose.Schema

 const UserSchema = new Schema({
    nickname: {
        type: String,
        minlength: 1,
        maxlength: 15,
        required: true
    },
    username: {
        type: String,
        unique: true,
        minlength: 6,
        maxlength: 15,
        required: true
    },
    password: {
        type: String,
        minlength: 6,
        maxlength: 15,
        required: true
    },
    sex: {
        type: Number,
        enum: [0,1,2], // 0保密 1女 2男
        default: 0
    },
    avatar: {
        type: String,
        required: true,
        default:'https://img2.baidu.com/it/u=3969906574,3231239394&fm=253&app=138&size=w931&n=0&f=PNG&fmt=auto?sec=1678899600&t=08a81527e591a5d3f4637527e1d22b83'
    },
    desc: {
        type: String,
        default: "这个人很懒，什么也没有写~"
    },
    active: {
        type: Boolean,
        default: true
    }
})

// 创建表
const userModel = mongoose.model('user', UserSchema)


module.exports = userModel

